package com.maixy.dailydemo.design.proxy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @ClassName MyTest
 * @Description TODO
 * @Date 2021/4/25 12:00
 * @Author maixy
 */
public class MyTest {
    public static void main(String[] args) {

        String[] names = {"tom", "tim", "allen", "alice"};
        Class<?> clazz = Test.class;

        try {
            Method method = clazz.getMethod("sayHi", String.class);
            for (String name : names)
                method.invoke(clazz.newInstance(), name);
        } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) {
            e.printStackTrace();
        }
    }
}
